<?php  

add_action('widgets_init', create_function('', 'return register_widget("ztmao_search");'));
class ztmao_search extends WP_Widget {
	function ztmao_search() {
		$widget_ops = array( 'classname' => 'ztmao_search', 'description' => '显示谷歌搜索框' );
		$this->__construct('ztmao_search', '谷歌搜索 ', $widget_ops);
	}

	function widget( $args, $instance ) {
		extract( $args );
		echo $before_widget;
		$action_url = $instance['action_url'];
		echo '<form method="get" action="'.$action_url.'"><div class="search-wrap"><div class="tt-autocomplete"><div class="tt-input tt-input-group tt-input-group--append"><input type="text" name="q" placeholder="找不到想看的？搜寻看看！" autocomplete="off" class="tt-input__inner"><div class="tt-input-group__append"><input type="submit" class="tt-button tt-button--default" value="搜寻"/></div></div></div></div></from>';
		echo $after_widget;
	}

	function form($instance) {
	    $instance = wp_parse_args( (array) $instance, array( 
			'action_url' => '/search'
			) 
		);
?>

<p>
	<label> 名称：
		<input id="<?php echo $this->get_field_id('action_url'); ?>" name="<?php echo $this->get_field_name('action_url'); ?>" type="text" value="<?php echo $instance['action_url']; ?>" class="widefat" />
	</label>
</p>

<?php
	}
}

?>
